package org.jeecg.modules.demo.zyHazardInvestigationFather.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.safemanage.zyhazardinvestigation.mapper.ZyHazardInvestigationMapper;
import org.jeecg.modules.demo.zyHazardInvestigationFather.entity.ZyHazardInvestigationFather;
import org.jeecg.modules.demo.zyHazardInvestigationFather.mapper.ZyHazardInvestigationFatherMapper;
import org.jeecg.modules.demo.zyHazardInvestigationFather.service.IZyHazardInvestigationFatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 整改监督父级
 * @Author: jeecg-boot
 * @Date:   2025-07-22
 * @Version: V1.0
 */
@Service
public class ZyHazardInvestigationFatherServiceImpl extends ServiceImpl<ZyHazardInvestigationFatherMapper, ZyHazardInvestigationFather> implements IZyHazardInvestigationFatherService {


    @Autowired
    private ZyHazardInvestigationMapper zyHazardInvestigationMapper;

    @Override
    public List<String> removeZyHazardInvestigation(String id) {
        // 查询选中节点下所有子节点一并删除
        List<String> ids = zyHazardInvestigationMapper.queryTreeChildIds(id);
        List<String> instantIds = zyHazardInvestigationMapper.queryInstantId(id);
        System.out.println("instantIds = " + instantIds);
        System.out.println("ids = " + ids);

        if (ids != null&&!ids.isEmpty()){
//            System.out.println("1 = " + 1);
            zyHazardInvestigationMapper.deleteBatchIds(ids);
        }
        return instantIds;
    }

    @Override
    public List<String> removeZyHazardInvestigationids(List<String> id) {
        List<String> instantIds = new ArrayList<>();
        List<String> ids=new ArrayList<>();
        for (int i = 0; i < id.size(); i++) {
            // 查询选中节点下所有子节点一并删除
        List<String> id1 = zyHazardInvestigationMapper.queryTreeChildIds(id.get(i));
        ids.addAll(id1);
        List<String> instantId = zyHazardInvestigationMapper.queryInstantId(id.get(i));
        instantIds.addAll(instantId);
        }
        System.out.println("ids = " + ids);
        if (ids != null &&!ids.isEmpty()){
//            System.out.println("1 = " + 1);
            zyHazardInvestigationMapper.deleteBatchIds(ids);
        }
        return instantIds;
    }
}
